package com.itheima.treemap;

import com.itheima.domain.Student;

import java.util.Set;
import java.util.TreeMap;

/*
TreeMap的使用
TreeMap  存储学生并遍历
学生当做键   值 地址
 */
public class Demo01 {

    public static void main(String[] args) {
        TreeMap<Student, String> map = new TreeMap<>();
        Student wu = new Student("wuyifan", 31);
        Student huang = new Student("huangzitao", 31);
        Student lu = new Student("luhan", 30);
        Student zhang = new Student("zhangyixing", 31);

        map.put(wu,"海淀监狱");
        map.put(huang,"泰然居");
        map.put(lu,"老军营");
        map.put(zhang,"汇大国际");
        Set<Student> students = map.keySet();
        for (Student student : students) {
            String address = map.get(student);
            System.out.println(student.getName()+"住在"+address);


        }


    }
}
